Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phong skinning #444

Closed
wants to merge 9 commits into from
Closed

Phong skinning #444

wants to merge 9 commits into from

Conversation

Squareys
Copy link
Contributor

Hi @mosra !

As mentioned in #441 , here's the split-off of the Phong implementation.

Best,
Jonathan

Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
Signed-off-by: Squareys <squareys@googlemail.com>
@mosra mosra mentioned this pull request May 11, 2020
3 tasks
@@ -913,43 +917,55 @@ void CompileGLTest::packedAttributes() {
const PackedVertex vertexData[]{
{Math::pack<Vector3s>(Vector3{-0.75f, -0.75f, -0.35f}),
Math::pack<Vector3s>(Vector3{-0.5f, -0.5f, 1.0f}.normalized()),
Math::pack<Vector2us>(Vector2{0.0f, 0.0f}), 0x00ff00_rgb, 13562},
Math::pack<Vector2us>(Vector2{0.0f, 0.0f}), 0x00ff00_rgb, 13562,
Vector4{0.4f, 0.3f, 0.2f, 0.1f}, Vector4us{0, 1, 2, 3}},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to have a non-trivial order, otherwise the test would pass also if it was doing matrices[i] instead of matrices[jointIds[i]]

src/Magnum/Shaders/Phong.vert Outdated Show resolved Hide resolved
Signed-off-by: Squareys <squareys@googlemail.com>
for(; i != JOINTS_PER_VERTEX && i != 4; ++i)
skinMatrix += weights[i]*jointMatrices[jointIds[i]];
#if JOINTS_PER_VERTEX > 4
for(i = 0; i != JOINTS_PER_VERTEX - 4 && i != 4; ++i)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be i != 8.

@@ -155,11 +186,25 @@ out highp vec3 cameraDirection;
#endif

void main() {
#ifdef SKINNING
mat4 skinMatrix;
Copy link
Contributor Author

@Squareys Squareys Sep 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be initialized with weights[0]*jointMatrices[jointIds[0]]. (And i should then start at 1)

@mosra mosra mentioned this pull request Sep 21, 2020
45 tasks
@mosra mosra mentioned this pull request May 4, 2021
@mosra mosra added this to the 2022.0a milestone Nov 14, 2022
@mosra
Copy link
Owner

mosra commented Dec 15, 2022

The shader code is merged as part of 89a6eb2. The shader code changed quite significantly since then so I was mostly just cherry-picking interesting bits from here, nevertheless -- thanks for the initial code, saved me a lot of time. The support is now extended to Flat and MeshVisualizer shaders as well, and works in instanced and multi-draw scenarios too.

The compile() support is merged as part of c026ac1. Compared to what was in this PR it had to deal with the additional complexity of the attributes being arbitrary arrays, and there's a new compiledPerVertexJointCount() helper for querying how many components in the builtin attribute slots get actually used in order to subsequently pass that info to the shader.

@mosra mosra closed this Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants